
import { _nav, _append, _layout, _events, _closest } from '../ui/index.js'
import { toggleInspector } from '../ui/g2.js'
import { hideAside } from '../ui/aside.js'
import config from '../data/nav3.js'

let app = document.getElementById("app")


let layout = _layout([".header", ".main .aside",
    ".main .screen-viewer", ".main .main-right .inspector",
    ".main .main-right .grammar", ".main .main-right .graphic"], app)
let [header, aside, screen, inspector] = layout
_events(screen, (e) => {
    let el = e.target
    hideAside()
    let panel =_closest(el,'.panel')
    if(/(webgl|^gl.*?)/.test( panel.getAttribute('name'))){
        return
    }
    let viewer = _closest(el, '.screen-viewer')
    if (!viewer) return
    toggleInspector('inspector')
})

// 下拉刷新
// let startY, endY, distance
// _events(document.body, {
//     touchstart: (e) => {
//         let touch = e.touches[0]
//         if (touch) {
//             startY = touch.clientY
//         }
//     },
//     touchmove: (e) => {
//         let touch = e.touches[0]
//         if (touch) {
//             endY = touch.clientY
//             distance = endY - startY
//         }
//     },
//     touchend: (e) => {
//         if (distance > 150) {
//             window.location.reload()
//         }
//     }
// })

let nav = _nav(config.menu, {
    ...config,
    root: app
})
_append(header, nav)
